package top.broncho.lottery.data

import androidx.room.RoomDatabase

inline fun <reified T> IRepositoryManager.obtainRetrofitService(): T =
    obtainRetrofitService(T::class.java)

inline fun <reified DB : RoomDatabase> IRepositoryManager.obtainRoomDatabase(): DB =
    obtainRoomDatabase(DB::class.java)

interface IRepositoryManager {

    /**
     * 根据传入的 Class 获取对应的 Retrofit service
     *
     * @param service
     * @param <T>
     * @return
    </T> */
    fun <T> obtainRetrofitService(service: Class<T>): T

    /**
     * 根据传入的 Class 获取对应的 Database
     *
     * @param database RoomDatabase Class
     * @param <DB>     RoomDatabase
     * @return RoomDatabase
    </DB> */
    fun <DB : RoomDatabase> obtainRoomDatabase(database: Class<DB>): DB

    /**
     * 清理所有缓存
     */
    fun clearAllCache()

}